package com.tueye.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tueye.base.util.BaseDao;
import com.tueye.base.util.IBaseHbnDao;
import com.tueye.dao.ITopicCommentDao;
import com.tueye.entity.TopicComment;
import com.tueye.entity.user.Flowers;

/**
 * 文章评论实现类
 * 
 * @author hanxiaowei
 * 
 */
@Scope("prototype")
@Component("topicCommentDao")
public class TopicCommentDaoImpl extends BaseDao implements ITopicCommentDao {

	@Autowired
	@Qualifier("baseHbnDao")
	private IBaseHbnDao baseHbnDao;

	@Override
	public void addTopicComment(TopicComment topicComment) {
		baseHbnDao.saveOrUpdate(topicComment);
	}

	@Override
	public void deleteTopicComment(String tcId) {
		TopicComment topicComment = (TopicComment) baseHbnDao.findById(TopicComment.class, tcId);
		baseHbnDao.delete(topicComment);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<TopicComment> getTopicCommentByHql(String hql) {

		return baseHbnDao.queryList(hql);
	}

	@Override
	public TopicComment getTopicCommentById(String tcId) {
		TopicComment topicComment = (TopicComment) baseHbnDao.findById(TopicComment.class, tcId);
		return topicComment;
	}

	@Override
	public void addFlowers(Flowers flowers) {
		baseHbnDao.saveOrUpdate(flowers);
	}

}
